import type { App } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import { routes } from './routes/index'

// 创建路由
const router = createRouter({
  history: createWebHashHistory(),
  routes,
  scrollBehavior: () => ({ top: 0, left: 0 })
})

// 全局注册 router
export function setupRouter(app: App<Element>) {
  app.use(router)
}

export function resetRouter() {
  router.replace({ path: '/login' })
}
